package cn.j0n4than.api.config;

import cn.j0n4than.api.interceptor.AuthAdminInterceptor;
import cn.j0n4than.api.interceptor.AuthUserInterceptor;
import cn.j0n4than.api.interceptor.CommonInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author jonathan
 */
@Slf4j
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("注册拦截器");
        registry.addInterceptor(new AuthUserInterceptor()).addPathPatterns("/api/user/**");
        registry.addInterceptor(new AuthAdminInterceptor()).addPathPatterns("/api/admin/**");
        registry.addInterceptor(new CommonInterceptor());
    }
}
